package com.applcn.shop.controller.merchant;

import com.applcn.core.base.Result;
import com.applcn.shop.dto.CreateShopDTO;
import com.applcn.shop.service.ShopService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * com.applcn.shop.controller.feign
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-02-25 00:49
 */
@RestController
@RequestMapping("/api/shop")
@RequiredArgsConstructor
public class ShopController {

    private final ShopService shopService;

    /**
     * 创建店铺
     *
     * @param dto
     * @return
     */
    @PostMapping("/createShop")
    public Result createShop(@RequestBody @Validated CreateShopDTO dto) {
        return shopService.createShop(dto);
    }

    /**
     * 查询用户店铺列表
     *
     * @return
     */
    @GetMapping("/userShopList")
    public Result userShopList(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                               @RequestParam(value = "pageSize", required = false, defaultValue = "9") Integer pageSize) {
        return shopService.userShopList(pageNum, pageSize);
    }
}
